<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>文件上传</title>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</head>
<body>
<input type="file" id="fileInput" />
<button onclick="uploadFile()">上传</button>

<script>
    function uploadFile() {
        var fileInput = document.getElementById('fileInput');
        var file = fileInput.files[0];
        if (!file) {
            alert('请选择一个文件');
            return;
        }

        var formData = new FormData();
        formData.append('file', file);

        axios.post('http://127.0.0.1:8005/file/upload', formData, {
            headers: {
                'Content-Type': 'multipart/form-data'
            }
        }).then(function(response) {
            alert('文件上传成功！');
        }).catch(function(error) {
            alert('文件上传失败！');
        });
    }
</script>
</body>
</html>
